package sistema;

import java.rmi.Naming;
import java.rmi.RemoteException;
import java.util.List;

import dominio.dto.ClienteTO;
import remoto.Igestion;

public class BD {

	private Igestion gestion;
	private static BD bd;
	
	private BD(){
		LookupService();
	}
	public static BD getInstance(){
		if(bd == null)
			bd = new BD();
		return bd;
	}
	
    private void LookupService() {
    	try {
    		String vinculo = "/Gestion";
			gestion = (Igestion)Naming.lookup (vinculo);
			System.out.println(vinculo);
		} catch (Exception e) {
			javax.swing.JOptionPane.showMessageDialog(null, e.getMessage());
		} 
    }

	public String getLibro(String nombre) throws RemoteException {
		String result = gestion.getLibro(nombre);
		return result;
	}
	public long prestar(String nombre, Long dni) throws RemoteException {
		long result = gestion.prestar(nombre, dni);
		return result;
	}
	public List<ClienteTO> getClientes(String param) throws RemoteException {
		return gestion.getClientes(param);
	}
}